<template>
	<view class="myComment">
		<view class="evaluated_btn" @tap="$to('/pages/mine/evaluated/evaluated')">
			<image src="/static/mine/pingjia_icon.png" mode=""></image>
			<view class="title">已评价</view>
			<uni-icons type="right" color="#333333" size="14"></uni-icons>
		</view>
		<view class="list">
			<block v-for=" (item,i) in list" :key="i">
				<view class="order_item">
					<view class="order_info">
						<image class="cover_img" :src="item.image" mode=""></image>
						<view class="">
							<view class="title">{{item.storeName}}</view>
							<view class="time">时间：{{item.payTime}}</view>
							<view class="other_info">
								<view class="tags" v-for="(v,idx) in getTag(item.label)">
									<view class="">{{v}}</view>
								</view>
								<view class="price">
									<text>￥</text>
									<text class="pirce_val">{{item.price}}</text>
								</view>
							</view>
						</view>
					</view>
					<view class="order_btns">
						<view class="btn_item" @tap="$to(`/pages/mine/evaluate/evaluate?id=${item.id}`)">去评价</view>

					</view>
				</view>
			</block>
			<view style="text-align: center;" v-if="list.length==0">
				<image style="width: 200rpx;height: 200rpx;" src="/static/nodata.png"></image>
				<view style="color: #999;text-align: center;">暂无数据</view>
			</view>
			<view style="text-align: center;color: #999;font-size: 24rpx;" v-if="noMoreData&&list.length!=0">
				没有更多啦
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				lastPage: 1,
				noMoreData: false,
				list: [],
			};
		},
		onShow(){
			this.getStayComment()
		},
		onReachBottom() {
			if (this.page < this.lastPage) {
				this.page += 1
				this.getStayComment()
			} else {
				this.noMoreData = true
			}
		},
		methods: {
			getTag(tag) {
				return tag.split(',')
			},
			async getStayComment() {
				const res = await this.$api.get('order/unrated', {
					page: this.page,
					limit: 10,
					search: ''
				});
				console.log(res, "待评价列表")
				if (res.code == 200) {
					const {
						list,
						totalPage
					} = res.data
					if (this.page == 1) {
						this.list = list || [];
						this.lastPage = totalPage || 1;
						// console.log(this.list, 'this.list')
					} else {
						this.list.push(...list);
					}
					this.page != 1 && list.length == 0 ? this.noMoreData = true : this.noMoreData = false
				}

			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f7f7f7;
	}

	.myComment {
		padding: 20rpx 26rpx;
		box-sizing: border-box;

		.evaluated_btn {
			width: 100%;
			height: 80rpx;
			background-color: #fff;
			border-radius: 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 26rpx;
			box-sizing: border-box;
			margin-bottom: 20rpx;

			image {
				width: 26rpx;
				height: 26rpx;
			}

			.title {
				flex: 1;
				font-size: 26rpx;
				font-weight: bold;
				margin: 0 20rpx;
			}
		}

		.list {
			.order_item {
				width: 100%;
				padding: 20rpx 26rpx 26rpx;
				box-sizing: border-box;
				background-color: #fff;
				border-radius: 20rpx;
				margin-bottom: 20rpx;

				.order_info {
					display: flex;
					align-items: flex-start;
					padding-bottom: 14rpx;
					border-bottom: 1rpx dashed #F0F0F0;
					margin-bottom: 26rpx;

					.cover_img {
						width: 200rpx;
						height: 160rpx;
						border-radius: 14rpx;
						margin-right: 16rpx;
					}

					>view {
						flex: 1;

						.title {
							width: 420rpx;
							font-size: 30rpx;
							line-height: 30rpx;
							font-weight: bold;
							color: #1A1A1A;
							overflow: hidden;
							white-space: nowrap;
							text-overflow: ellipsis;
						}

						.time {
							font-size: 24rpx;
							line-height: 24rpx;
							color: #999999;
							padding: 14rpx 0 22rpx;
						}

						.other_info {
							display: flex;
							justify-content: space-between;

							.tags {
								display: flex;
								align-items: center;

								>view {
									font-size: 22rpx;
									line-height: 22rpx;
									padding: 8rpx 12rpx;
									color: #FF8F01;
									background-color: #FFF2E2;
								}

								>view:not(:last-child) {
									margin-right: 20rpx;
								}
							}

							.price {
								font-size: 24rpx;
								font-weight: bold;
								color: #FF0404;

								.pirce_val {
									font-size: 34rpx;
									color: #FF0000;
								}
							}
						}
					}
				}

				.order_btns {
					display: flex;
					justify-content: flex-end;

					.btn_item {
						width: 120rpx;
						height: 46rpx;
						border-radius: 10rpx;
						text-align: center;
						line-height: 46rpx;
						color: #fff;
						font-size: 24rpx;
						background-color: #2E80FE;
					}
				}
			}
		}
	}
</style>